package com.lxc.graduation.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lxc.graduation.dao.*;
import com.lxc.graduation.entity.domain.*;
import com.lxc.graduation.entity.response.DocumentDetails;
import com.lxc.graduation.service.DocumentDetailsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: ck
 * @Description:
 * @Date: Create in 13:03 2021/3/7
 */
@Service
@Slf4j
public class DocumentServiceImpl implements DocumentDetailsService {
   @Autowired
   private ElementMapper elementMapper;
   @Autowired
   private IssueMapper issueMapper;
   @Autowired
   private LawMapper lawMapper;
   @Autowired
   private LinkMapper linkMapper;
   @Autowired
   private PointMapper pointMapper;
   @Autowired
   private DocumentRecommendMapper documentRecommendMapper;
    @Override
    public DocumentDetails listById(Integer docId) {
        DocumentDetails documentDetails = new DocumentDetails();
        documentDetails.setDocumentRecommend(documentRecommendMapper.selectById(docId));
        documentDetails.setElements(elementMapper.selectList(new QueryWrapper<Element>().eq("doc_id",docId)));
        documentDetails.setIssues(issueMapper.selectList(new QueryWrapper<Issue>().eq("doc_id",docId)));
        documentDetails.setLaws(lawMapper.selectList(new QueryWrapper<Law>().eq("doc_id",docId)));
        documentDetails.setLinks(linkMapper.selectList(new QueryWrapper<Link>().eq("doc_id",docId)));
        documentDetails.setPoints(pointMapper.selectList(new QueryWrapper<Point>().eq("doc_id",docId)));


        return documentDetails;
    }
}
